//javamaps
//Copyright (c) 2010 Bebeselea Elena
package Data;
import Core.Marker;
import java.util.*;
import Core.*;
import java.io.*;

public class MarkerLayer implements ILayer, Serializable{
    private ObjectId ID_;
    private String name_;
    private String icon_;
    private int markerNumber_;
    private java.util.Map<ObjectId, Marker> markers_;

    /*
     * Constructori.
     */
     public MarkerLayer(){
        ID_ = new ObjectId(0);
        name_ = "";
        icon_ = "";
        markerNumber_ = 0;
        markers_ = new HashMap<ObjectId, Marker>();
     }

     public MarkerLayer(ObjectId ID, String name, String icon){
        ID_ = ID;
        name_ = name;
        icon_ = icon;
        markerNumber_ = 0;
        markers_ = new HashMap<ObjectId, Marker>();
     }

     /*
     * Metode publice.
     */
     public ObjectId ID(){ return ID_; }
     public void SetID(ObjectId ID){ ID_ = ID; }

     public String Name(){ return name_; }
     public void SetName(String name){ name_ = name; }

     public LayerType Type(){ return LayerType.Marker; }

     public String Icon(){ return icon_; }
     public void SetIcon(String icon){ icon_ = icon; }

     public int MarkerNumber(){ return markerNumber_; }
     public void SetMarkerNumber(int markerNumber){ markerNumber_ = markerNumber; }

     //Metode ce ofera acces la HashMap-ul markers_.
     public Marker GetMarker(ObjectId ID){ return markers_.get(ID); }
     public void Add(ObjectId ID, Marker marker){
         markers_.put(ID, marker );
         markerNumber_++;
     }
     public boolean Contains(ObjectId ID){ return  markers_.containsKey(ID); }
     public void Remove(ObjectId ID){
         markers_.remove(ID);
         markerNumber_ --;
     }
     public void Clear(){ 
         markers_.clear();
         markerNumber_ = 0;
     }

     public Iterator<Marker> Iterator(){
         Collection c = markers_.values();
         Iterator i = c.iterator();
         return i;
     }
}
